package core.service.impl;

import java.io.Serializable;
import java.util.List;

import javax.transaction.Transactional;

import org.springframework.beans.factory.annotation.Autowired;

import core.dao.BaseDao;
import core.service.BaseService;

@Transactional
public abstract class BaseServiceImpl<E> implements BaseService<E> {

	@Autowired
	protected BaseDao<E> baseDao;

	@Override
	public void save(E entity) {
		baseDao.add(entity);
	}

	@Override
	public void delete(E entity) {
		baseDao.delete(entity);
	}

	@Override
	public void update(E entity) {
		baseDao.update(entity);
	}

	@Override
	public List<E> listAll() {
		return baseDao.findAll();
	}

	public long conut() {
		return baseDao.count();
	}

	@Override
	public E get(Serializable id) {
		return (E) baseDao.get(id);
	}
	@Override
	public E load(Serializable id) {
		return (E) baseDao.load(id);
	}

	@Override
	public List<E> listPage(int pos, int rows) {
		return baseDao.find(pos, rows);
	}

}